package roborally.script.singleCommand;

import roborally.model.Energy;
import roborally.model.Robot;
import roborally.script.SingleCommand;
import be.kuleuven.cs.som.annotate.*;
import be.kuleuven.cs.som.taglet.*;

/**
 * @author Joren VERSPEURT
 * @author Mathieu REYMOND
 * @version 3.0
 * 
 * The class representing a Shoot command. When stepped it makes the Robot shoot.
 */
public class Shoot extends SingleCommand {

	/**
	 * Create a new Shoot command with a given Robot.
	 * @param robot The Robot this Shoot command will apply to.
	 */
	public Shoot(Robot robot) {
		super(robot);
	}
	
	/**
	 * Makes <code>robot</code> shoot, if it still has enough energy to do so.
	 */
	@Override
	public void step() {
		super.step();
		
		if(robot.getEnergy().getValueIn(Energy.Unit.WS) >= Robot.getEnergyRequiredToShoot().getValueIn(Energy.Unit.WS)) {
			robot.shoot();
		}
	}
	
	/**
	 * The script word for this command.
	 */
	@Override
	public String toString() {
		return "shoot";
	}
}
